<%-- 
    Document   : agent
    Created on : May 4, 2012, 3:46:43 PM
    Author     : Jayson Kiong
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="Model.Agent"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="Cache-Control" content="no-cache">
        <meta http-equiv="Expires" content="Sat, 01 Dec 2001 00:00:00 GMT">
        <link rel = "stylesheet" type = "text/css" href = "quicklendstyle.css"/>
        <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.19.custom.css" rel="stylesheet" />
        <script src="gen_validatorv4.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="js/jquery-ui-1.8.19.custom.min.js"></script>
        <script type="text/javascript" src="quicklendjs.js"></script>
        <title>Agent Page</title>
        <script type="text/javascript">
		$(function(){

			// Accordion
			$("#accordion").accordion({ header: "h3" });

			// Tabs
			$('#tabs').tabs();

			// Dialog
			$('#dialog').dialog({
				autoOpen: false,
				width: 600,
				buttons: {
					"Ok": function() {
						$(this).dialog("close");
					},
					"Cancel": function() {
						$(this).dialog("close");
					}
				}
			});
				// Dialog Link
			$('#dialog_link').click(function(){
				$('#dialog').dialog('open');
				return false;
			});
				// Datepicker
			$('#datepicker').datepicker({
				inline: true
			});
				// Slider
			$('#slider').slider({
				range: true,
				values: [17, 67]
			});
				// Progressbar
			$("#progressbar").progressbar({
				value: 20
			});
				//hover states on the static widgets
			$('#dialog_link, ul#icons li').hover(
				function() { $(this).addClass('ui-state-hover'); },
				function() { $(this).removeClass('ui-state-hover'); }
			);
                            
                            
			});
                        
                     
	</script>
        
    </head>
    <body>
        <%ArrayList ar = (ArrayList)session.getAttribute("agent");
          int arctr = 0;
          Agent agent = new Agent();
          int arsize = ar.size();  
        %>
        <div id="head" style="position:absolute;top:12px;left:25px; font-family:segoe ui;font-size:20px;color:#EBBD05;font-weight:600">
            Agents
        </div>
        <div id="tabs" style="position:absolute;width:850px;height:580px;top:50px;left:20px; border:none; font-size:11px">
		<ul>
                    <li><a href="#tabs-1">Add Agent</a></li>
                    <li><a href="#tabs-2">Agent List</a></li>
				
		</ul>
                <div id="tabs-1">
                    <form id="addagentform" action="/Quicklend/AddAgentServlet" method="POST">
                    </br>
                    <table style="font-family:segoe ui; font-size:12px;">
                        <tr>
                            <td><b>Agent Code</b></td><td><input type="text" style="width:130px;" name="agentcode"><div id='addagentform_agentcode_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>Last Name:</td><td><input type="text" style="width:130px;" name="lastname"><div id='addagentform_lastname_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>First Name:</td><td><input type="text" style="width:130px;" name="firstname"><div id='addagentform_firstname_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>Middle Name:</td><td><input type="text" style="width:130px;" name="middlename"><div id='addagentform_middlename_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>No. & Street:</td><td><input type="text" style="width:130px;" name="street"><div id='addagentform_street_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>Town/City/Province:</td><td><input type="text" style="width:130px;" name="city"><div id='addagentform_city_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>Zip:</td><td><input type="text" style="width:130px;" name="zip"><div id='addagentform_zip_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>Email:</td><td><input type="text" style="width:130px" name="email"><div id='addagentform_email_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>Contact No.</td><td><input type="text" style="width:130px;" name="contact"><div id='addagentform_contact_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        <tr>
                            <td>Remarks:</td><td><input type="text" style="width:130px;" name="remarks"></td>
                        </tr>
                        <tr>
                            <td>Commission:</td><td><input type="text" style="width:130px;" value="0.03" name="commission"><div id='addagentform_commission_errorloc' style="color:#FF0000"></div></td>
                        </tr>
                        
                    </table>
                    <div id="agentfunction" style="position:absolute; top:500px; left:500px; font-family: segoe ui;">
                    <input type="image" src="images/saveimage.png" size="13" style="position:absolute; left:0px"/>
                    <a href="#" class="precompcancelbtn" name="precompcancelbtn"  size="13" style="position:absolute; left:170px"/></a>
                    </div>
                    </form>
                </div>
            
                <div id="tabs-2">
                
                <div id="typetable" style="position:absolute; top:60px; left:25px; font-family: segoe ui; font-size:11px;overflow: auto; width: 800px; height: 400px; padding:0px; margin: 0px; ">
                                <table border="1" cellspacing=0 cellpadding=2>
                                <COL WIDTH=300><COL WIDTH=250><COL WIDTH=250>
                                <tr>
                                    <th width=300 bgcolor="lightgrey">Agentcode</th>
                                    <th width=250 bgcolor="lightgrey">Name</th>
                                    <th width=250 bgcolor="lightgrey">Contact No.</th>
                                    <th width=250 bgcolor="lightgrey">E-mail</th>
                                    <th width=250 bgcolor="lightgrey">Street</th>
                                    <th width=250 bgcolor="lightgrey">City</th>
                                    <th width=250 bgcolor="lightgrey">Zip</th>
                                    <th width=250 bgcolor="lightgrey">Remarks</th>
                                    <th width=250 bgcolor="lightgrey">Commission</th>
                                    <th bgcolor="lightgrey">Function</th>

                                </tr>
                                <%
                                  for(int x=0;x<arsize;x++){
                                  agent=(Agent)ar.get(arctr);%>                   
                                  <tr><td><%=agent.getStrAgentcode()%></td><td><%=agent.getStrName()%></td><td><%=agent.getStrContact()%></td><td><%=agent.getStrEmail()%></td><td><%=agent.getStrStreet()%></td><td><%=agent.getStrCity()%></td><td><%=agent.getiZip()%></td><td><%=agent.getStrRemarks()%></td><td><%=agent.getfCommission()%></td><td><input type="button" name="edit" value="Edit" style="background-color:#49743D;font-weight:bold;color:#ffffff;" onclick="editRecord(<%=agent.getiID()%>)" ></td><td style="display:none;"><input type="hidden" name="id" value="<%=agent.getiID()%>"></td></tr> 
                                <%arctr++;}%>


                                </table>
                </div>

                <div id="typebutton" style="position:absolute; top:500px; left:325px; font-family: segoe ui;">
                    <a href="#" class="refreshbtn" name="refreshbtn"  size="13" style="position:absolute; left:340px"/><img src="images/refreshbtnimage.png" alt=""></img></a>

                </div>
                </div>
            
        </div>
    </body>
    <script type="text/javascript">
         var frmvalidator  = new Validator("addagentform");
         frmvalidator.addValidation("firstname","req","Please enter the First Name");
         frmvalidator.addValidation("lastname","req","Please enter the Last Name");
         frmvalidator.addValidation("middlename","req","Please enter the Middle Name");
         frmvalidator.addValidation("agentcode","req","Please enter the Agent Code");
         frmvalidator.addValidation("street","req","Please enter the Street");
         frmvalidator.addValidation("city","req","Please enter the City");
         frmvalidator.addValidation("email","req","Please enter the Email Address");
         frmvalidator.addValidation("email","email","Invalid Email Address");
         frmvalidator.addValidation("zip","req","Please enter the Zip");
         frmvalidator.addValidation("zip","num","Invalid Zip");
         frmvalidator.addValidation("contact","req","Please enter the Contact No.");
         frmvalidator.addValidation("commission","req","Please enter the Agent's Commission");
         frmvalidator.addValidation("commission","num","Invalid Agent's Commission");
         frmvalidator.addValidation("contact","num","Invalid contact no.");
         frmvalidator.EnableOnPageErrorDisplay();
         frmvalidator.EnableMsgsTogether();
    </script>

</html>
